﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Log
{
    public class Log4NetProvider : ILoggerProvider
    {
        #region 变量/构造函数

        private log4net.ILog _log;

        #endregion 变量/构造函数

        #region ILogger接口实现

        public Log4NetProvider()
        {

        }
        public Log4NetProvider(string _name)
        {
            _log = log4net.LogManager.GetLogger(_name);
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="_name"></param>
        public void Init(string _name)
        {
            _log = log4net.LogManager.GetLogger(_name);
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="_type"></param>
        public void Init(Type _type)
        {
            _log = log4net.LogManager.GetLogger(_type);
        }

        /// <summary>
        /// 记录Debug信息状态位
        /// </summary>
        public bool IsDebugEnabled
        {
            get { return this._log.IsDebugEnabled; }
        }

        /// <summary>
        /// 记录Info信息状态位
        /// </summary>
        public bool IsInfoEnabled
        {
            get { return this._log.IsInfoEnabled; }
        }

        /// <summary>
        /// 记录Warning信息状态位
        /// </summary>
        public bool IsWarnEnabled
        {
            get { return this._log.IsWarnEnabled; }
        }

        /// <summary>
        /// 记录Error信息状态位
        /// </summary>
        public bool IsErrorEnabled
        {
            get { return this._log.IsErrorEnabled; }
        }

        /// <summary>
        /// 记录Fatal信息状态位
        /// </summary>
        public bool IsFatalEnabled
        {
            get { return this._log.IsFatalEnabled; }
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="message"></param>
        public void Debug(object message)
        {
            this._log.Debug(message);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public void Debug(object message, System.Exception exception)
        {
            this._log.Debug(message, exception);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        public void DebugFormat(string format, object arg0)
        {
            this._log.DebugFormat(format, arg0);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        public void DebugFormat(string format, object arg0, object arg1)
        {
            this._log.DebugFormat(format, arg0, arg1);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        public void DebugFormat(string format, object arg0, object arg1, object arg2)
        {
            this._log.DebugFormat(format, arg0, arg1, arg2);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void DebugFormat(string format, params object[] args)
        {
            this._log.DebugFormat(format, args);
        }

        /// <summary>
        /// 记录Debug信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void DebugFormat(IFormatProvider provider, string format, params object[] args)
        {
            this._log.DebugFormat(provider, format, args);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="message"></param>
        public void Info(object message)
        {
            this._log.Info(message);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public void Info(object message, System.Exception exception)
        {
            this._log.Info(message, exception);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        public void InfoFormat(string format, object arg0)
        {
            this._log.InfoFormat(format, arg0);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        public void InfoFormat(string format, object arg0, object arg1)
        {
            this._log.InfoFormat(format, arg0, arg1);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        public void InfoFormat(string format, object arg0, object arg1, object arg2)
        {
            this._log.InfoFormat(format, arg0, arg1, arg2);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void InfoFormat(string format, params object[] args)
        {
            this._log.InfoFormat(format, args);
        }

        /// <summary>
        /// 记录Info信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void InfoFormat(IFormatProvider provider, string format, params object[] args)
        {
            this._log.InfoFormat(provider, format, args);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="message"></param>
        public void Warn(object message)
        {
            this._log.Warn(message);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public void Warn(object message, System.Exception exception)
        {
            this._log.Warn(message, exception);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        public void WarnFormat(string format, object arg0)
        {
            this._log.WarnFormat(format, arg0);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        public void WarnFormat(string format, object arg0, object arg1)
        {
            this._log.WarnFormat(format, arg0, arg1);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        public void WarnFormat(string format, object arg0, object arg1, object arg2)
        {
            this._log.WarnFormat(format, arg0, arg1, arg2);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void WarnFormat(string format, params object[] args)
        {
            this._log.WarnFormat(format, args);
        }

        /// <summary>
        /// 记录Warning信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void WarnFormat(IFormatProvider provider, string format, params object[] args)
        {
            this._log.WarnFormat(provider, format, args);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="message"></param>
        public void Error(object message)
        {
            this._log.Error(message);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public void Error(object message, System.Exception exception)
        {
            this._log.Error(message, exception);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        public void ErrorFormat(string format, object arg0)
        {
            this._log.ErrorFormat(format, arg0);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        public void ErrorFormat(string format, object arg0, object arg1)
        {
            this._log.ErrorFormat(format, arg0, arg1);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        public void ErrorFormat(string format, object arg0, object arg1, object arg2)
        {
            this._log.ErrorFormat(format, arg0, arg1, arg2);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void ErrorFormat(string format, params object[] args)
        {
            this._log.ErrorFormat(format, args);
        }

        /// <summary>
        /// 记录Error信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
        {
            this._log.ErrorFormat(provider, format, args);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="message"></param>
        public void Fatal(object message)
        {
            this._log.Fatal(message);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public void Fatal(object message, System.Exception exception)
        {
            this._log.Fatal(message, exception);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        public void FatalFormat(string format, object arg0)
        {
            this._log.FatalFormat(format, arg0);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        public void FatalFormat(string format, object arg0, object arg1)
        {
            this._log.FatalFormat(format, arg0, arg1);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arg0"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        public void FatalFormat(string format, object arg0, object arg1, object arg2)
        {
            this._log.FatalFormat(format, arg0, arg1, arg2);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void FatalFormat(string format, params object[] args)
        {
            this._log.FatalFormat(format, args);
        }

        /// <summary>
        /// 记录Fatal信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void FatalFormat(IFormatProvider provider, string format, params object[] args)
        {
            this._log.FatalFormat(provider, format, args);
        }

        #endregion ILogger接口实现
    }
}
